/*****************************************************************************
*   uart.h:  Header file for uart.c
*		ver 1.0	
******************************************************************************/
#include "me32g030.h"

#ifndef __ME32G030_UART_H__
#define __ME32G030_UART_H__

#ifdef __cplusplus
 extern "C" {
#endif


//stauts and int bit
#define UART_NO_PARITY 							0x0 
#define UART_EVEN_PARITY 						0x1
#define UART_ODD_PARITY 						0x2
#define UART_BIT9_ENABLE						0x3
	 
#define UART_RX_INT 							0x01
#define UART_TX_INT 							0x02
#define UART_RX_LINE_INT 					0x04
#define UART_MODEM_INT						0x08 
#define UART_XOFF_INT						  0x20
#define UART_RTS_INT              0x40 
#define UART_CTS_INT							0x80

	 
#define UART_TRIGGER_LEVEL_1_BYTE 		0x0	 
#define UART_TRIGGER_LEVEL_4_BYTES 		0x1	 
#define UART_TRIGGER_LEVEL_8_BYTES 		0x2
#define UART_TRIGGER_LEVEL_14_BYTES 	0x3

#define UART_ONE_STOP_BIT						 	0x0
#define UART_TWO_STOP_BITS						0x1

#define EndSimulation								while(!(UART0->LSR_b.THRE));UART0->THR=0x04;
__STATIC_INLINE void EndSimulationTest(UART0_Type *uart)
{ 
	while(!(UART0->LSR_b.THRE));
	UART0->THR=0x04;
}

void UART_Open(UART0_Type *uart, uint32_t baudrate, uint8_t parityoption, uint8_t rxinttriggerlevel);
void UART_Close(UART0_Type *uart);
uint8_t UART_ByteRead(UART0_Type *uart, uint8_t *data);
void UART_Read(UART0_Type *uart, uint8_t * rxbuf, uint8_t *readBytes);
uint8_t UART_ByteWrite(UART0_Type *uart, uint8_t data);
uint8_t UART_Write(UART0_Type *uart, uint8_t * txbuf, uint8_t writebytes);
void UART_Send(UART0_Type *uart, uint8_t * txbuf, uint32_t sendbytes);
void UART_PutString (UART0_Type *uart, uint8_t * str);
void UART_PutHex (UART0_Type *uart, uint32_t data);
void UART_EnableInt(UART0_Type *uart, uint32_t intcon);
void UART_DisableInt(UART0_Type *uart);
void UART_ClearFIFO(UART0_Type *uart);
void UART_EnableIrDA(UART0_Type *uart);
void UART_DisableIrDA(UART0_Type *uart);



#ifdef __cplusplus
  }
#endif

#endif /* end __ME32G030_UART_H */
/*****************************************************************************
**                            End Of File
******************************************************************************/
